package com.geping.etl.common.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
import com.geping.etl.common.entity.Sys_Menu;
import org.springframework.transaction.annotation.Transactional;

/**
 * 
 * @author Mr.chen
 *	菜单权限  Sys_Menu
 */
@Repository
public interface Sys_MenuRepository extends PagingAndSortingRepository<Sys_Menu, Integer>{
	
	@Query("select sm from Sys_Menu sm where sm.subjectId = ?1 order by id ASC")
	public List<Sys_Menu> getMenuBySubjectId(String subjectId);

	@Query(value = "SELECT * FROM SYS_MENU WHERE ID = (SELECT MAX(ID) FROM SYS_MENU)", nativeQuery = true)
	Sys_Menu finMax();

	@Modifying
	@Query("delete from Sys_Menu a where a.url like concat('%',?1,'%') ")
	int deleteMenu(String panelId);
} 
